import { defineStore } from 'pinia'
import { reactive, toRefs } from 'vue'

const useCommonStore = defineStore(
  'common',
  () => {
    const state = reactive({
      collapsed: false,
      requestKeys: {},
      requestUrls: []
    })

    function addRequestKes(key, value) {
      state.requestKeys[key] = value
    }
    function removeRequestKeys(key) {
      delete state.requestKeys[key]
    }

    return {
      addRequestKes,
      removeRequestKeys,
      ...toRefs(state)
    }
  },
  {
    persist: {
      storage: localStorage,
      paths: ['']
    }
  }
)

export default useCommonStore
